package com.s3.khospitalds.controller;

import com.s3.khospitalds.common.R;
import com.s3.khospitalds.common.ResponseEntity;
import com.s3.khospitalds.entity.TableShift;
import com.s3.khospitalds.service.TableShiftService;
import com.s3.khospitalds.service.impl.TableShiftServiceImpl;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author: xw
 * @CreateTime: 2025/2/20
 * @Description: 护士轮班类
 * @Version: 1.0
 */
@RestController
@CrossOrigin(origins = "*")
public class TableShiftController {
    @Autowired
    private TableShiftServiceImpl tableShiftService;
    @GetMapping("/getTableShift")
    public ResponseEntity getTableShift(Integer pageNum, Integer pageSize, String searchDepartment, String searchName, String searchTimes) {//查询所有护士轮班表
        pageNum = pageNum == null ? 1 : pageNum;
        pageSize = pageSize == null ? 10 : pageSize;
        searchDepartment = searchDepartment == null ? "" : searchDepartment;
        searchName = searchName == null ? "" : searchName;
        searchTimes = searchTimes == null ? "" : searchTimes;
        return tableShiftService.selectAll(pageNum,pageSize,searchDepartment,searchName,searchTimes);
    }
    @PostMapping("/insertTableShift")
    public R insertTableShift(@RequestBody TableShift tableShift) {//新增护士轮班表
        return new R().addData("tableShift",tableShiftService.insert(tableShift));
    }
    @PostMapping("/updateTableShift")
    public R updateTableShift(@RequestBody TableShift tableShift) {//修改护士轮班表
        return new R().addData("tableShift",tableShiftService.update(tableShift));
    }
    @PostMapping("/deleteTableShift")
    public R deleteTableShift(@RequestBody Integer id) {//根据id删除护士轮班信息
        return new R().addData("tableShift",tableShiftService.delete(id));
    }
}